import { defineStore } from 'pinia'
import { getStorage, setStorage } from '@/utils/storage'
import { ref, reactive } from "vue"


export const useAppStore = defineStore('app', () => {

	const lang = ref(getStorage('lang') || 'zh-Hans')


	const setLang = (v : string) => {
		lang.value = v
	}

	return {
		lang,
		setLang
	}
}, {
	persist: {
		pick: ['lang'],
		storage: {
			getItem: (key : string) => {
				return getStorage(key)
			},
			setItem: (key : string, value : any) => {
				setStorage(key, value)
			}
		}
	}

})